<?php
class Users_model extends CI_Model {
	
	function __construct() {
		// call the Model constructor
		parent::__construct();
		// load database class and connect to MySQL
		$this->load->database();
	}
	
	function getAllUsers() {
		$this->load->database();
		$query = $this->db->get('users');
		if ($query->num_rows () > 0) {
			// return result set as an associative array
			return $query->result_array();
		}
	}
	
	function getUsersWhere($field, $param) {
		$this->db->where($field, $param);
		$query = $this->db->get('users');
		// return result set as an associative array
		return $query->result_array();
	}
	
	// get total number of users
	function getNumUsers() {
		
//		$this->load->database();
		 return $this->db->count_all('users');
//		 return 10;
	}
}
?>